
/*
 * @项目名称: 模板开发
 * @FilePath: /meek/src/renderer/render/drawPoint.js
 * @Author: 1159657388@qq.com
 * @Date: 2020-07-17T09:19:20+08:00
 * @LastEditors: 447508585@qq.com
 * @LastEditTime: 2023-03-13 15:44:49
 * Copyright (c) 2018-2022 
 */

import pointrender from './pointrender'
import {
  colorToString
} from '../../utils/helpers'

/**
 *
 * @param ctx
 * @param feature
 * @param styleArray
 * @param renderCoords
 */

export function drawPoint(ctx, renderCoords, feature, styleArray) {
  if (!feature.showPoint && feature.showDrawPoint) {
    const len = styleArray.length
    for (let i = 0; i < len; i++) {
      let styleObj = styleArray[i]
      for (let j = 0; j < renderCoords[0].length; j++) {
        let renderOptions = {
          centerX: renderCoords[0][j][0] | 0,
          centerY: renderCoords[0][j][1] | 0,
          radius: feature.readuis,
          fillStyle: colorToString(styleObj.color),
          borderStyle: styleObj.borderStyle
        }
        pointrender.prototype.drawCircle(ctx, renderOptions);
      }
    }
  }
}


export function drawPointIndexes(ctx, coords, opt) {
    ctx.save()
    if (opt && opt.pointIndexTextSize) {
	    ctx.font = 'normal ' + opt.pointIndexTextSize + 'px Arial';
	  } else {
	    ctx.font = 'normal 14px Arial';
	  }
    ctx.strokeStyle = colorToString([0, 0, 255], 1)
    ctx.fillStyle = colorToString( [0, 0, 255], 1)
    ctx.textBaseline = 'middle'
    ctx.textAlign = 'center'
    ctx.lineWidth = 0
    ctx.lineCap = 'round'
    ctx.lineJoin = 'round'
    coords.forEach((coord, index) => {
      ctx.fillText(index + 1 + "", coord[0] + 5, coord[1] - 5);
    });
    ctx.restore();
  }
